package com.mode.mvvm;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.mode.R;
import com.mode.databinding.ActivityMvvmBinding;
import com.mode.mvvm.bean.User;

public class MVVMActivity extends AppCompatActivity {

    User user;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_mvvm);
        ActivityMvvmBinding mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_mvvm);
        user = new User("asda", 18);
        mainBinding.setUserInfo(user);
    }

    public void change(View view) {
        user.age.set(0);
        user.name.set("yym");
    }
}